using System.Collections.ObjectModel;
using Neuparts.Ordering.Entities;
using Neuparts.Ordering.ServiceInterface.DataContracts;

namespace Neuparts.Ordering.ServiceInterface.Translators
{
    public class CustomerOrderTranslator
    {
        public static OrderContract Translate(Order from)
        {
            var to = new OrderContract();
            to.Customer = new CustomerContract();
            to.Customer.BillTo = new AddressContract();
            to.Customer.ShipTo = new AddressContract();
            to.OrderDetail = new Collection<OrderDetailContract>();

            to.Customer.BillTo.Street1 = from.Customer.BillTo.Street1;
            to.Customer.BillTo.Street2 = from.Customer.BillTo.Street2;
            to.Customer.BillTo.City = from.Customer.BillTo.City;
            to.Customer.BillTo.State = from.Customer.BillTo.State;
            to.Customer.BillTo.ZIP = from.Customer.BillTo.ZIP;
            to.Customer.ShipTo.Street2 = from.Customer.ShipTo.Street2;
            to.Customer.ShipTo.City = from.Customer.ShipTo.City;
            to.Customer.ShipTo.State = from.Customer.ShipTo.State;
            to.Customer.ShipTo.ZIP = from.Customer.ShipTo.ZIP;
            // to.Customer.Company = from.Customer.Company;
            to.Customer.Id = from.Customer.Id;
            to.Customer.Name = from.Customer.Name;

            to.Id = from.Id.Value;
            to.IsShipped = from.IsShipped;
            to.OrderDate = from.OrderDate;

            return to;
        }
    }
}